package com.atguigu.day16.math01;

import org.junit.Test;
/*
Math类:
   1.final class Math
   2.private Math() {}
   3.java.lang;
   4.//todo 静态导入 导入类中所有的静态资源
          import static java.lang.Math.*;
 */
public class MathTest {

    @Test
    public void test0(){

        System.out.println("Math.PI = " + Math.PI);// 3.141592653589793
        System.out.println("Math.E = " + Math.E);//2.718281828459045

    }
    @Test
    public void test02(){
        //绝对值 MAth.abs(-10);==10
        System.out.println("Math.abs(-10) = " + Math.abs(-10));
        System.out.println("Math.abs(10) = " + Math.abs(10));
        //开平方 Math.sqrt(9);==3
        System.out.println("Math.sqrt(9) = " + Math.sqrt(9));
        System.out.println("Math.sqrt(25) = " + Math.sqrt(25));
        //x^y
        System.out.println("Math.pow(2,3) = " + Math.pow(2, 3));
        System.out.println("Math.pow(3,3) = " + Math.pow(3, 3));
        //向上取整
        System.out.println("Math.ceil(1.1) = " + Math.ceil(1.1));
        System.out.println("Math.ceil(2.1) = " + Math.ceil(2.1));
        //向下取整
        System.out.println("Math.floor(3.9) = " + Math.floor(3.9));
        System.out.println("Math.floor(4.9) = " + Math.floor(4.9));

    }
    @Test
    public void test03(){
        //[22,33]
        //(int)(Math.random()*(n-m+1)+m)
        for (int i = 0; i < 100; i++) {
            //[0,1)
           /* double random = Math.random();
            System.out.println("random = " + random);*/
            int num = (int)(Math.random()*(33-22+1)+22);
            System.out.println("num = " + num);
        }
    }

    @Test
    public void test04(){
        //四舍五入
        System.out.println("Math.round(3.9) = " + Math.round(3.9));
        System.out.println("Math.round(3.2) = " + Math.round(3.2));
        System.out.println("Math.max(20,30) = " + Math.max(20, 30));
        System.out.println("Math.min(3,9) = " + Math.min(3, 9));

    }
}
